<template>
  <div class="home-page">
    <MainMenu />
    
    <main class="main-content">
      <div class="content-header">
        <h1 class="page-title">{{ pageTitle }}</h1>
        <div class="header-actions">
          <button @click="toggleFullscreen" class="action-btn" title="全屏">
            <i :class="isFullscreen ? 'icon-minimize' : 'icon-maximize'"></i>
          </button>
        </div>
      </div>
      
      <div class="content-body">
        <router-view />
      </div>
    </main>
  </div>
</template>

<script setup lang="ts">
import { computed, ref, onMounted, onUnmounted } from 'vue'
import { useRoute } from 'vue-router'
import MainMenu from '@/components/navigation/MainMenu.vue'

const route = useRoute()
const isFullscreen = ref(false)

const pageTitle = computed(() => {
  const titleMap: Record<string, string> = {
    '/': '首页',
    '/chat': '聊天界面',
    '/contacts': '联系人',
    '/history': '聊天记录',
    '/demo/layout': '响应式布局演示',
    '/demo/components': 'UI 组件演示',
    '/demo/themes': '主题系统演示',
    '/settings': '系统设置',
    '/profile': '个人资料'
  }
  
  return titleMap[route.path] || '未知页面'
})

const toggleFullscreen = () => {
  if (!document.fullscreenElement) {
    document.documentElement.requestFullscreen()
    isFullscreen.value = true
  } else {
    document.exitFullscreen()
    isFullscreen.value = false
  }
}

const handleFullscreenChange = () => {
  isFullscreen.value = !!document.fullscreenElement
}

onMounted(() => {
  document.addEventListener('fullscreenchange', handleFullscreenChange)
})

onUnmounted(() => {
  document.removeEventListener('fullscreenchange', handleFullscreenChange)
})
</script>

<style scoped>
.home-page {
  display: flex;
  height: 100vh;
  background: var(--color-background);
  color: var(--color-text);
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-lg) var(--spacing-xl);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  min-height: 60px;
}

.page-title {
  margin: 0;
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
}

.header-actions {
  display: flex;
  gap: var(--spacing-sm);
}

.action-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.action-btn:hover {
  background: var(--color-hover);
  color: var(--color-text);
}

.content-body {
  flex: 1;
  overflow: hidden;
  background: var(--color-background);
}

/* 图标样式 */
.icon-maximize::before { content: '⛶'; }
.icon-minimize::before { content: '⊟'; }

/* 响应式设计 */
@media (max-width: 768px) {
  .content-header {
    padding: var(--spacing-md) var(--spacing-lg);
  }
  
  .page-title {
    font-size: var(--font-size-lg);
  }
}
</style>